package com.example.provider.config

import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Primary
import org.springframework.data.mongodb.MongoDatabaseFactory
import org.springframework.jdbc.datasource.DataSourceTransactionManager
import javax.sql.DataSource
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.data.mongodb.MongoTransactionManager
import org.springframework.transaction.PlatformTransactionManager


@Configuration
class TransactionConfig {
//    @Bean
//    fun mongoTransactionManager(mongoDbFactory: MongoDatabaseFactory?): MongoTransactionManager {
//        return MongoTransactionManager(mongoDbFactory!!)
//    }
    @Bean
    fun transactionManager(@Qualifier("dataSource") dataSource: DataSource): PlatformTransactionManager {
        return DataSourceTransactionManager(dataSource)
    }

}
